package com.tanhua.model.vo;

import com.tanhua.model.db.UserInfo;
import com.tanhua.model.mongo.PeachBlossomAudio;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.beans.BeanUtils;

//桃花传音返回Vo对象
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PeachBlossomVo {

    //UserInfo数据
    private Long userId; //用户id
    private String avatar;
    private String nickname;
    private String gender; //性别 man woman
    private Integer age;

    private ObjectId audioId;
    private String soundUrl; //语音地址
    private Integer remainingTimes; //当日可获取语音数量,默认值为10 每获取一次该值-1


    public static PeachBlossomVo init(UserInfo userInfo, PeachBlossomAudio item) {
        PeachBlossomVo vo = new PeachBlossomVo();

        //设置语音数据
        vo.setAudioId(item.getId());
        vo.setSoundUrl(item.getAudioUrl());

        //设置用户数据
        BeanUtils.copyProperties(userInfo, vo);
        vo.setUserId(userInfo.getId());

        //语音列表

        //返回数据
        return vo;
    }
}
